from openai import OpenAI
from langchain.chat_models import ChatOpenAI
from langchain.schema import SystemMessage,HumanMessage

# from langchain.llms import OpenAI
# llm = OpenAI("gpt-3.5-turbo")
# gpt-3.5-turbo

client = OpenAI(
    api_key='hk-mtiquv1000041663a49a34520ad3294132cbce7abf1c2ef3',
    base_url="https://api.openai-hk.com/v1"
)
chat = ChatOpenAI(api_key='hk-mtiquv1000041663a49a34520ad3294132cbce7abf1c2ef3',
    base_url="https://api.openai-hk.com/v1")

res = chat([HumanMessage(content='你是谁？')])
print(res)
# completion = client.chat.completions.create(
#     model="gpt-3.5-turbo",
#     messages=[{"role": "user", "content": "用七言绝句的形式写一首关于学习的诗"}]
# )
#
# print(completion.choices[0].message.content)

# from langchain_openai import ChatOpenAI
# from langchain_core.messages import HumanMessage, SystemMessage
# from langchain.agents import initialize_agent
# from langchain.agents.agent_toolkits import ZapierToolkit
# from langchain.utilities.zapier import ZapierNLAWrapper
# from langchain.llms import OpenAI

# chat = ChatOpenAI(
#     model="gpt-3.5-turbo",
#     temperature=0.3,
#     max_tokens=200,
#     api_key="hk-mtiquv1000041663a49a34520ad3294132cbce7abf1c2ef3",
#     base_url="https://api.openai-hk.com/v1"
# )
#
# messages = [
#     SystemMessage(content="你是一名精通了大数据架构"),
#     HumanMessage(content="三十而立立的是哪三样"),
# ]
# agent = initialize_agent(toolkit.get_tools(), llm, agent="zero-shot-react-description", verbose=True)
#
#
# response = chat.invoke(messages)
#
# print(response.content)

# import os
#
# os.environ['OPENAI_API_KEY'] = 'hk-mtiquv1000041663a49a34520ad3294132cbce7abf1c2ef3'
#
# os.environ['ZAPIER_NLA_API_KEY'] = 'hk-mtiquv1000041663a49a34520ad3294132cbce7abf1c2ef3'
#
# llm = OpenAI(temperature=.3)
# zapier = ZapierNLAWrapper()
# toolkit = ZapierToolkit.from_zapier_nla_wrapper(zapier)
# agent = initialize_agent(toolkit.get_tools(), llm, agent="zero-shot-react-description", verbose=True)
# # 我们可以通过打印的方式看到我们都在 Zapier 里面配置了哪些可以用的工具
# for tool in toolkit.get_tools():
#   print (tool.name)
#   print (tool.description)
#   print ("\n\n")
# agent.run('请用中文总结最后一封"******@qq.com"发给我的邮件。并将总结发送给"1243774355@qq.com"')



# https://openai-hk.com/v3/ai/
# https://blog.csdn.net/rubys007/article/details/140486754